Custom RapidSpellDialog User Interface

Layout/Style

It is easy to customize the UI used by the RapidSpellDialog control. The example projects include full source code for the default UIs, which can be modified by hand or in the Visual Studio designer. It's also possible to implement the lightweight IDialogView interface from scratch and use any class as a UI (eg. built on 3rd party forms).

Assuming IDialogView has been implemented already (see demos), the class is used by handling the CreateDialogView event in RapidSpellDialog, and setting an instance of the class (which implements IDialogView) in the event argument's NewView property.

C#

    private void rapidSpellDialog1_CreateDialogView(object sender, Keyoti.RapidSpell.Event.CreateDialogViewEventArgs e)
    {
         e.NewView = new CustomGUIView();
    }

VB.NET

    Sub rapidSpellDialog1_CreateDialogView(ByVal sender As System.Object, _
	    ByVal e As Keyoti.RapidSpell.Event.CreateDialogViewEventArgs) Handles rapidSpellDialog1.CreateDialogView
        e.NewView = New CustomGUIView
    End Sub

The above assumes that CustomGUIView is a class implementing IDialogView.

Options And User Dictionary Editor

Similarly, the CreateDialogViewOptions, CreateDialogViewUserDictionarySelect and CreateDialogViewUserDictionaryEdit events allow substitution of the default UIs for option and user dictionary editing. Please see the demo projects for full source.

Behavior

It is easy to customize the UI behavior used by the RapidSpellDialog control. This is done by subclassing "RapidSpellGUIPresenter" which is the logic behind the RapidSpellDialog user interface. RapidSpellGUIPresenter has methods which react to user input and also controls the Form, which it holds in it's "DialogView" property (this is actually the instance returned via the "CreateDialogView" event, see above).

To use a subclass of RapidSpellGUIPresenter, handle the RapidSpellDialog.CreateUserInterfaceFormPresenter event.

C#

    private void rapidSpellDialog1_CreateUserInterfaceFormPresenter(object sender, Keyoti.RapidSpell.Event.CreateUserInterfaceFormPresenterEventArgs e)
    {
       e.NewPresenter = new CRapidSpellGUIPresenter();
    }

VB.NET

    Sub rapidSpellDialog1_CreateUserInterfaceFormPresenter(ByVal sender As System.Object, _
	    ByVal e As Keyoti.RapidSpell.Event.CreateUserInterfaceFormPresenterEventArgs) Handles rapidSpellDialog1.CreateUserInterfaceFormPresenter
        e.NewPresenter = new CRapidSpellGUIPresenter()
    End Sub

This sets the instance of the RapidSpellGUIPresenter subclass "CRapidSpellGUIPresenter" in the event property.

Consult the API docs (under namespaces) for details of the various methods which can be overridden. As an example, consider the case where the "change" buttons should be disabled when there are no suggestions. The CRapidSpellGUIPresenter class would look like this.

C#

    public class CRapidSpellGUIPresenter : RapidSpellGUIPresenter
    {
        
        protected override void Resume()
        {
            base.Resume();
            System.Collections.ArrayList suggs;            
            suggs = CheckerEngine.FindSuggestions();            

            DialogView.ChangeAllButtonEnabled = suggs.Count > 0;
            DialogView.ChangeButtonEnabled = suggs.Count > 0;
        
        }
	}

The Resume method is called every time a word is shown as an error to the user, and the opportunity is taken to look at how many suggestions there are (using the CheckerEngine property). When there are no suggestions the change buttons are disabled (note how they are accessed via the DialogView property, which returns the IDialogView instance in use).